<template>
    <Modal
            v-model="show"
            title="添加"
            @on-ok="save"
            @on-cancel="close"
    >
        <i-form ref="formFilter" label-position="right" :label-width="100">
                    <form-item label="标题：">
                <i-input v-model="dto.title"  autocomplete="off" spellcheck="false" type="text" placeholder="标题" />
            </form-item>
            <form-item label="创建用户id：">
                <i-input v-model="dto.userId"  autocomplete="off" spellcheck="false" type="text" placeholder="创建用户id" />
            </form-item>
            <form-item label="创建人昵称：">
                <i-input v-model="dto.userNickName"  autocomplete="off" spellcheck="false" type="text" placeholder="创建人昵称" />
            </form-item>
            <form-item label="手机号：">
                <i-input v-model="dto.mobile"  autocomplete="off" spellcheck="false" type="text" placeholder="手机号" />
            </form-item>
            <form-item label="邮箱：">
                <i-input v-model="dto.email"  autocomplete="off" spellcheck="false" type="text" placeholder="邮箱" />
            </form-item>
            <form-item label="详细内容：">
                <i-input v-model="dto.detail"  autocomplete="off" spellcheck="false" type="text" placeholder="详细内容" />
            </form-item>
            <form-item label="地址：">
                <i-input v-model="dto.address"  autocomplete="off" spellcheck="false" type="text" placeholder="地址" />
            </form-item>
            <form-item label="来源：">
                <i-input v-model="dto.source"  autocomplete="off" spellcheck="false" type="text" placeholder="来源" />
            </form-item>
            <form-item label="联系方式：">
                        联系方式:
                <i-select clearable label-in-value v-model="dto.typeTest">
                    <i-option v-for="item in typeTestData" :value="item.val" :key="item.val" :lable="item.lab">{{ item.lab }}</i-option >
                </i-select>
            </form-item>
            <form-item label="状态：">
                        状态:
                <i-select clearable label-in-value v-model="dto.status">
                    <i-option v-for="item in statusData" :value="item.val" :key="item.val" :lable="item.lab">{{ item.lab }}</i-option >
                </i-select>
            </form-item>
        </i-form>
    </Modal>
</template>

<script>
    module.exports = {
        props:[],
        data() {
            return {
                show:false,
                dto:{
                    title:undefined,
                    userId:undefined,
                    userNickName:undefined,
                    mobile:undefined,
                    email:undefined,
                    detail:undefined,
                    address:undefined,
                    source:undefined,
                    typeTest:undefined,
                    status:undefined,
                },
                typeTestData:[
                    {
                        val:'WX',
                        lab:'微信',
                    },
                    {
                        val:'QQ',
                        lab:'QQ',
                    },
                    {
                        val:'PHONE',
                        lab:'手机号',
                    },
                ],
                statusData:[
                    {
                        val:'true',
                        lab:'正常',
                    },
                    {
                        val:'false',
                        lab:'作废',
                    },
                ],
                createdDate:undefined,
                }
        },
        mounted() {

        },
        methods:{
            save() {
                let _this = this;
                _this.loading=true;
                ipost('/admin/news2',
                    _this.dto,
                    successRes => {
                        this.$Notice.success({
                            title: '保存成功'
                        });
                        _this.show=false;
                        _this.dto=cleanParams(_this.dto);
                        this.$emit("save",successRes.data);
                    },failureRes => {
                        console.info("加载数据异常asdfg",failureRes)
                        this.$Notice.error({
                            title: '系统异常'
                        });
                    }
                )
            },
            dateChange(e,name){
                this.dto[name]=e.toString().length<2?undefined:e.toString();
            },
        }
    }
</script>
